Micro addon support #1
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This is a temporary PR where we can keep the discussion and have an overview of changes before the micro addon feature is ready to be merged into ember-cli/ember-cli.
Once the feature is ready, we can delete this PR and create a new one against ember-cli/ember-cli#master
ToDo
Final PR Description
This PR adds support to micro addons to ember-cli.
Premise
The idea here is to enable usage of a type of ember addon in which the file structure is greatly simplified. Micro-components, micro-helpers and micro-libraries are supported within the current PR.
Using coderly's CLI tool, we are able to generate a micro-addon of a specific type with a single command.
However, in order to be able to use such an addon out of the box, we are forced to have a modified
index.jswhich usestreeFor[Name]hooks in order to make the addon compatible with an Ember-CLI app. Basically, the logic which makes a micro-addon work is exposed.Making Ember-CLI support this feature internally would hide away this logic and open up the road for additional CLI tools.
For example, with another command, we can almost instantly publish the micro-addon to github:
It is also possible to extract a component, helper or library out of an existing app into a micro-addon.
Finally, we have a command available which converts a micro-addon into a proper ember-addon
The output is placed within
/addon-name/dist.The end result is a greatly simplified and sped up workflow. We can create and publish a micro-addon in under 20 seconds, or extract part of an ember application into an addon just as quickly.
Implementation
The micro-addon files are organized in a completely flat file structure with the following files
package.jsonfor all addons. Needs to containember-addonas well asember-micro-addonkeywordsindex.jsfor all addons, Looks pretty much the same asindex.jsin a regular ember addoncomponent.js, template.hbsandstyle.css` in the case of a micro-componenthelper.jsin the case on a micro-helperlibrary.jsin the case of a micro-libraryAt build time, a micro-addon's files get renamed and moved so the micro-addon temporarily gets a proper addon structure. They are then available for import from the
app/components,app/helpersoraddon/libnamespace, depending on the type of addon.